<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>v-on指令</title>
  <script src="../vue.js"></script>
  <style>
    .box {
      border: 3px solid #000000;
      border-radius: 10px;
      padding: 20px;
      margin: 20px;
      width: 200px;
    }

    h3 {
      margin: 10px 0 20px 0;
    }

    p {
      margin: 20px;
    }
  </style>
</head>

<body>
  <!-- 
    v-on:作用:注册事件+处理逻辑
    v-on:   简写成   @ 

    函数:
    @+事件+methods中的函数名
   -->
  <div id="app">
    <button v-on:mouseenter="count--"> - </button>
    <span> {{ count }}</span>
    <button v-on:click="count++"> + </button>

    <button @click="isShow"> 按钮点击切换 </button>
    <p v-show="show">前端程序员</p>

    <h4 align="center">调用传参</h4>
    <div class="box">
      <h3>小黑自动售货机</h3>
      <button @click="fn1(5)">可乐5元</button>
      <button @click="fn2(10)">咖啡10元</button>
    </div>
    <p>银行卡余额：{{money}}元</p>
  </div>
  <script>
    const app = new Vue({
      el: '#app',
      data: {
        count: 100,
        show: true,
        money: 100
      },
      methods: {
        isShow() {
          this.show = !this.show
        },
        fn1(a = 0) {
          this.money = this.money - a
        },
        fn2(b = 0) {
          this.money = this.money - b
        }
      }
    })
  </script>
</body>

</html>